package memory.GUI;

import java.awt.GridLayout;
import javax.swing.JPanel;
import memory.Board;

/**
 *
 * @author Scott Robinson
 */
public class MemoryBoardPanel extends JPanel {
    
    private Board mb;    
    private final SquarePanel sp [][];
    private static final int PREF_SIZE = 70;

    public MemoryBoardPanel ( Board board) {
        this(PREF_SIZE, board);
    }

    public MemoryBoardPanel (int prefSize, Board board) {
        this.mb = board;
        sp = new SquarePanel[mb.getRows()][mb.getColumns()];
        setLayout(new GridLayout(mb.getRows(),mb.getColumns(), 10, 10));
        
        for (int r = 0; r < mb.getRows()  ; r++ ) {
            for (int c = 0; c < mb.getColumns() ; c++ ) {
                sp [r][c] = new SquarePanel(prefSize, mb.getSquare(r, c));
                //sp[r][c].displayImage();
                add(sp[r][c]);
            }
        }
    }

    public SquarePanel getSquare(int row, int column) {
        return sp[row][column];
    }

    public Board getMemoryBoard() {
        return mb;
    }

    public SquarePanel[][] getAllSquares() {
        return sp;
    }




    
    



}
